(function(){

    // 地址
    let url = location.href
    console.log(url);

    // 解析地址
    let param= getUrlParams(url);
    console.log(param);


    // 获取解析地址数据
    let title = param.title
    console.log(title);


    let productid =param.productid
    console.log(productid);

    let categoryid = param.categoryid
    console.log(categoryid);

    // fetch获取数据渲染页面
    fetch(`http://chst.vip:1234/api/getproduct?productid=${productid}`)
    .then(body=>body.json())
    .then(res=>{
        console.log(res);
        let result= res.result[0]
        // console.log(result);
        // ${result.}
        let html=
        `
        <div class="info_1">
        <a href="/index.html">首页></a>
        <a href="/pages/bija-1.html?title=${title}&categoryid=${categoryid}">${title}></a>
        <a href="#">${result.productName.split(" ")[0]}</a>
        <p>筛选</p>
        </div>
        <div class="info">
        <div>  
       ${result. productImg}
       <i>${result.productName}</i>
        </div>
        <p>${result.bjShop}</p>
        </div>
        
        `
        $('#nav').html(html)

    })

    // http://chst.vip:1234/api/getproductcom
    fetch(`http://chst.vip:1234/api/getproductcom?productid=${productid}`)
    .then(body=>body.json())
    .then(res=>{
        console.log(res);
        // let result= res.result[0]
        // console.log(result);

        let {result:thing}=res
        console.log(thing);
        let html = ''
        thing.forEach(item => {
            html+=
            `
        <div class="mate">
            <div class="one">
                <p>${item.comName}</p> 
                <i>${item.comTime}</i>
            </div>
            <div class="two">${item.comContent}
            </div>
            <div class="three">
                <span>${item.comFrom}</span>
            </div>
        </div>
            
            `
            $('#content ').html(html)
        });
  
    })

})()